﻿using System;
using System.Collections.Generic;
using System.Text;

namespace skydream
{
    public class ReaderHelp
    {
        /// <summary>
        /// 吧数据反序操作！
        /// </summary>
        /// <returns></returns>
        public static string reverse(string str)
        {
            int zu = str.Length / 2;
            string temp = null;
            for (int i = 0; i < zu; i++)
            {//查看需要交换几组
                temp += str.Substring((zu * 2 - (i + 1) * 2), 2).ToUpper();
            }
            return temp;
        }
        /// <summary>
        /// 转化成需要的字符串数组
        /// 1。转为16进制数据
        /// 2。调换位置
        /// 3。专成需要的字符数据
        /// </summary>
        /// <param name="inistr"></param>
        /// <returns>标志位1.16进制转为10进制数据</returns>
        /// <returns>补齐位数</returns>
        /// <returns>数据</returns>
        public static Int64 getWritten(string str, int num, bool bzw)
        {
            string wstr = null;
            if (str.Length == 8)
            {

                if (bzw)
                    wstr = "00" + str.Substring(6, 2) + str.Substring(4, 2) + str.Substring(2, 2) + str.Substring(0, 2);
                else
                    wstr = str.Substring(6, 2) + str.Substring(4, 2) + str.Substring(2, 2) + str.Substring(0, 2);
            }
            Int64 istr = Convert.ToInt64(wstr, 16);
            return istr; 

            //string str = buffer.ToString().PadLeft(num, '0');
            //string wstr = null;
            //if (str.Length == 8)
            //{

            //    if (bzw)
            //        wstr = "00" + str.Substring(6, 2) + str.Substring(4, 2) + str.Substring(2, 2) + str.Substring(0, 2);
            //    else
            //        wstr = str.Substring(6, 2) + str.Substring(4, 2) + str.Substring(2, 2) + str.Substring(0, 2);
            //}
            //Int64 istr = Convert.ToInt64(wstr, 16);
            //return istr;
        }
    }
}
